@page "/"

@using Blazored.LocalStorage;
@using StudentVideo.Client.Common.Constants;

@inject NavigationManager Navigation;
@inject ILocalStorageService LocalStorage;

@code
{
   protected override async Task OnAfterRenderAsync(bool firstRender)
   {
      await base.OnAfterRenderAsync(firstRender);

      var token = await LocalStorage.GetItemAsync<string>(LocalStorageKeys.Token);
      if (string.IsNullOrEmpty(token))
      {
         Navigation.NavigateTo(PagePath.Login, new NavigationOptions { ReplaceHistoryEntry = true });
      }
      else
      {
         Navigation.NavigateTo(PagePath.Home);
      }

   }
}
